using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using Cocos2D;

namespace Tester
{
	[Register("AppDelegate")]
	public class AppDelegate : UIApplicationDelegate
	{
		private UIWindow _window;
		
		private void setupCocos2D()
		{
			Director director = Director.SharedDirector;
			
			if (!Director.SetDirectorType(DirectorType.DisplayLink))
			{
				Console.WriteLine("Using NSTimer (default) director.");
				Director.SetDirectorType(DirectorType.Default);
			}
			
			director.DeviceOrientation = DeviceOrientation.LandscapeRight;
			director.DisplayFPS = true;
			director.AttachInWindow(_window);
		}
		
		public override void FinishedLaunching(UIApplication application)
		{
			UIApplication.SharedApplication.StatusBarHidden = true;
			
			_window = new UIWindow(UIScreen.MainScreen.Bounds);
			_window.UserInteractionEnabled = true;
			_window.MultipleTouchEnabled = true;
			
			setupCocos2D();
			
			_window.MakeKeyAndVisible();
			
			var ms = new MenuScene();
			Director.SharedDirector.RunWithScene(ms);
		}
	}
}
